/**
 * 
 */
let bussRegister = new Vue({
	el:'#bussRegister',
	data:{
		percentage:0,
		imageUrl:'',
		divActive:[
			{div:true,index:0},
			{div:false,index:1},
			{div:false,index:2}
		],
		bussDetails:{
			bname:'',
			bpro:'',
			bimg:null,
			bcity:'',
			baddress:'',
			number:'',
			bdetails:''
		},
		areaList:[
			{area:'北京'},
			{area:'天津'},
			{area:'上海'},
			{area:'重庆'},
			{area:'河北'},
			{area:'山西'},
			{area:'辽宁'},
			{area:'吉林'},
			{area:'黑龙江'},
			{area:'江苏'},
			{area:'浙江'},
			{area:'安徽'},
			{area:'福建'},
			{area:'江西'},
			{area:'山东'},
			{area:'河南'},
			{area:'湖北'},
			{area:'湖南'},
			{area:'广东'},
			{area:'海南'},
			{area:'四川'},
			{area:'贵州'},
			{area:'云南'},
			{area:'陕西'},
			{area:'甘肃'},
			{area:'青海'},
			{area:'台湾'},
			{area:'内蒙古'},
			{area:'广西'},
			{area:'西藏'},
			{area:'宁夏'},
			{area:'新疆'},
			{area:'香港'},
			{area:'澳门'},
		]
	},
	methods:{
		uploadUserImg(item){
			//console.log(item);
			this.imageUrl = URL.createObjectURL(item.file);//blobUrl
			console.log(this.imageUrl);
			this.bussDetails.bimg = item.file;
		},
		submitbuss(){
			let data = new FormData();
			data.append("bname",this.bussDetails.bname);
			data.append("bpro",this.bussDetails.bpro);
			data.append("bimg",this.bussDetails.bimg);
		
			data.append("baddress",this.bussDetails.baddress);
			data.append("number",this.bussDetails.number);
			data.append("bdetails",this.bussDetails.bdetails);
			axios.post('/buss/add',data).then(resp=>{
				this.percentage = 100;
				if(resp.data==='注册成功，请等待审核'){
					this.$message.success(resp.data+",正在跳转到首页");
					setTimeout(()=>{
						window.location.href="http://localhost:8082/";
					},2000);
				}
					
				else{
					this.$message.error("注册失败，请正确填写");
				}
			}).catch(error=>{
				console.log('注册时的错误信息：'+error);
			});
		},
		process(p){
			return p===100?'已完成':'未完成';
		},
		nextBtn(index){
			if(index<2){
				this.divActive[index].div = false;
				this.divActive[index+1].div = true;
				this.percentage+=100/3;
			}
		},
		backBtn(index){
			if(index>0){
				this.divActive[index].div = false;
				this.divActive[index-1].div = true;
				this.percentage-=100/3;
			}
		}
	}
});